const http = require('http')
const server = http.createServer((req,res)=>{
    const {pathname,query} = require('url').parse(req.url,true)
    console.log(pathname,query)

    const buffer = []
    req.on('data',(chunk)=>{
        buffer.push(chunk)
    })
    req.on('end',()=>{
        let obj = Buffer.concat(buffer).toString()
        console.log(req.headers)
        if(req.headers['content-type']  === 'application/json'){
            console.log(JSON.parse(obj))
        }
    })

    res.statusCode = 200
    res.setHeader('content-type','text/html;charset=utf8')
    res.end('哈哈哈')
})
server.listen(3000)
